<template>
  <el-dialog
    append-to-body
    :title="title"
    center
    :visible.sync="openState"
    width="1024px"
    :close-on-click-modal="false"
  >
    <el-form ref="queryDetail" :model="form" label-width="120px">
      <!--交易础信息-->
      <el-card class="form-card">
        <div slot="header" class="label-header-msg">
          <span>交易基础信息</span>
        </div>
        <el-row>
          <el-col :span="8">
            <el-form-item label="交易流水号" prop="id">
              <el-input v-model="form.id" disabled/>
            </el-form-item>
          </el-col>

          <el-col :span="8">
            <el-form-item label="工作日期" prop="workdate">
              <el-date-picker v-model="form.workdate" style="width: 100%" type="date" value-format="yyyyMMdd" disabled/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="业务优先级" prop="bizPriority">
              <el-select style="width: 100%;" v-model="form.bizPriority" placeholder="业务优先级" disabled>
                <el-option
                  v-for="dict in dictMap.PRIORITY3CODE"
                  :key="dict.value"
                  :label="`${dict.value}-${dict.text}`"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="报文标识号" prop="pkgId">
              <el-input v-model="form.pkgId" disabled/>
            </el-form-item>
          </el-col>

          <el-col :span="8">
            <el-form-item label="通讯状态" prop="status">
              <el-select style="width: 100%;" v-model="form.status" placeholder="通讯状态" disabled>
                <el-option
                  v-for="dict in dictMap.STATUS_115"
                  :key="dict.value"
                  :label="`${dict.value}-${dict.text}`"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="8">
            <el-form-item label="来往账方向" prop="drct">
              <el-select style="width: 100%" v-model="form.drct" placeholder="来往账方向" disabled>
                <el-option
                  v-for="dict in dictMap.DRCTCODE"
                  :key="dict.value"
                  :label="`${dict.value}-${dict.text}`"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="业务类型" prop="bizTypeCode">
              <el-select style="width: 100%" v-model="form.bizTypeCode" placeholder="业务类型" disabled>
                <el-option
                  v-for="dict in dictMap.BIZ_TYPE_115"
                  :key="dict.value"
                  :label="`${dict.value}-${dict.text}`"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="业务种类" prop="bizCtgyCode">
              <el-select style="width: 100%" v-model="form.bizCtgyCode" placeholder="业务种类" disabled>
                <el-option
                  v-for="dict in dictMap.BIZ_CTGY"
                  :key="dict.value"
                  :label="`${dict.value}-${dict.text}`"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="8">
            <el-form-item label="交易币种" prop="curcd">
              <el-input v-model="form.curcd" placeholder="货币种类" :disabled="true"   disabled/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="金额" prop="amount">
              <ht-amount-input v-model="form.amount" placeholder="交易金额"  :disable="true"></ht-amount-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="大写金额" prop="bAmount">
              <ht-amount-upper :inputValue="form.amount" placeholder="交易金额" ></ht-amount-upper>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-row>
            <el-col :span="24">
              <el-form-item label="备注" prop="remarks">
                <el-input type="textarea" v-model="form.remarks" disabled/>
              </el-form-item>
            </el-col>
          </el-row>
        </el-row>
      </el-card>

      <!--付款人信息-->
      <el-card class="form-card">
        <div slot="header" class="label-header-msg">
          <span>付款人信息</span>
        </div>
        <el-row :gutter="10">
          <el-col :span="12">
            <el-form-item label="付款人账号" prop="payerActno">
              <el-input v-model="form.payerActno" placeholder="付款人账号" disabled/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="付款行行号" prop="payerBrno">
              <el-input v-model="form.payerBrno" placeholder="付款行行号" disabled/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-form-item label="付款人名称" prop="payerName">
            <el-input v-model="form.payerName" placeholder="付款人名称" disabled/>
          </el-form-item>
        </el-row>
        <el-row>
          <el-form-item label="付款人地址" prop="payerAddr">
            <el-input v-model="form.payerAddr" placeholder="付款人地址" disabled/>
          </el-form-item>
        </el-row>
        <el-row :gutter="10">
          <el-col :span="8">
            <div class="grid-payer">
              <el-form-item label="付款人开户行号" prop="payerAccBrno">
                <el-input v-model="form.payerAccBrno" placeholder="付款人开户行行号" disabled/>
              </el-form-item>
            </div>
          </el-col>
          <el-col :span="16">
            <el-form-item label="付款人开户行行名" prop="payerAccBrname" label-width="130px">
              <el-input v-model="form.payerAccBrname" placeholder="付款人开户行行名" disabled/>
            </el-form-item>
          </el-col>
        </el-row>
      </el-card>

      <!--收款人信息-->
      <el-card class="form-card">
        <div slot="header" class="label-header-msg">
          <span>收款人信息</span>
        </div>
        <el-row :gutter="10">
          <el-col :span="12">
            <el-form-item label="收款人账号" prop="payeeActno">
              <el-input v-model="form.payeeActno" placeholder="收款人账号" disabled/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="收款行行号" prop="payeeBrno">
              <el-input v-model="form.payeeBrno" placeholder="收款行行号" disabled/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-form-item label="收款人名称" prop="payeeName">
          <el-input v-model="form.payeeName" placeholder="收款人名称" disabled/>
        </el-form-item>
        <el-form-item label="收款人地址" prop="payeeAddr">
          <el-input v-model="form.payeeAddr" placeholder="收款人地址" disabled/>
        </el-form-item>
        <el-row :gutter="10"></el-row>
        <el-row :gutter="10">
          <el-col :span="8">
            <div class="grid-payee">
              <el-form-item label="收款人开户行号" prop="payeeAccBrno">
                <el-input v-model="form.payeeAccBrno" placeholder="收款人开户行行号" disabled/>
              </el-form-item>
            </div>
          </el-col>
          <el-col :span="16">
            <el-form-item label="收款人开户行行名" prop="payeeAccBrname" label-width="130px">
              <el-input v-model="form.payeeAccBrname" placeholder="收款人开户行行名" disabled/>
            </el-form-item>
          </el-col>
        </el-row>
      </el-card>

      <el-card class="form-card">
        <div slot="header" class="label-header-msg">
          <span>中介信息</span>
        </div>
        <el-row :gutter="10">
          <el-col :span="8">
            <div class="grid-payer">
              <el-form-item label="中介机构1" prop="agency1">
                <el-input v-model="form.agency1" placeholder="中介机构1" disabled/>
              </el-form-item>
            </div>
          </el-col>
          <el-col :span="16">
            <el-form-item label="中介机构1名称" prop="agency1name" label-width="130px">
              <el-input v-model="form.agency1name" placeholder="中介机构1名称" disabled/>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row :gutter="10">
          <el-col :span="8">
            <div class="grid-payer">
              <el-form-item label="中介机构2" prop="agency2">
                <el-input v-model="form.agency2" placeholder="中介机构2" disabled/>
              </el-form-item>
            </div>
          </el-col>
          <el-col :span="16">
            <el-form-item label="中介机构2名称" prop="agency2name" label-width="130px">
              <el-input v-model="form.agency2name" placeholder="中介机构2名称" disabled/>
            </el-form-item>
          </el-col>
        </el-row>
      </el-card>

      <el-card class="form-card" v-if="this.form.bizCtgyCode==='02105'||this.form.bizCtgyCode==='02118'||this.form.bizCtgyCode==='02119'||this.form.bizCtgyCode==='02120'||this.form.bizCtgyCode==='02121'||this.form.bizCtgyCode==='02126'">
        <div slot="header" class="label-header-msg">
          <span>行内资金汇划信息</span>
        </div>
        <el-row>
          <el-col :span="12">
            <el-form-item label="拆借期限" prop="lendDline">
              <el-input v-model="form.lendDline" disabled/>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="拆借利率(单位:万分之一)" prop="lendIntRate">
              <el-input v-model="form.lendIntRate" disabled/>
            </el-form-item>
          </el-col>
        </el-row>
      </el-card>
      <el-card class="form-card" v-else>
        <div slot="header" class="label-header-msg">
          <span>跨境信息</span>
        </div>

        <el-row>
          <el-col :span="12">
            <el-form-item label="关联业务委托日期" prop="cbbizAssocBizDate">
              <el-date-picker v-model="form.cbbizAssocBizDate" style="width: 100%;" type="date" value-format="yyyyMMdd" disabled/>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="费用编码" prop="cbbizFeeCode">
              <el-select style="width: 100%;" v-model="form.cbbizFeeCode" placeholder="费用编码" disabled>
                <el-option
                  v-for="dict in dictMap.FEE_CODE"
                  :key="dict.value"
                  :label="`${dict.value}-${dict.text}`"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="发报行货币" prop="cbbizSndbnkCurcd">
              <el-input v-model="form.cbbizSndbnkCurcd" placeholder="发报行货币" :disabled="true"   disabled/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="发报行的收费" prop="cbbizSndbnkFee">
              <ht-amount-input v-model="form.cbbizSndbnkFee" placeholder="发报行的收费"  :disable="true"></ht-amount-input>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="12">
            <el-form-item label="收报行货币" prop="cbbizRcvbnkCurcd">
              <el-input v-model="form.cbbizRcvbnkCurcd" placeholder="收报行货币" :disabled="true"   disabled/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="收报行的收费" prop="cbbizRcvbnkFee">
              <ht-amount-input v-model="form.cbbizRcvbnkFee" placeholder="收报行的收费"  :disable="true"></ht-amount-input>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="24">
            <el-form-item label="跨境业务附言" prop="cbbizRemark">
              <el-input type="textarea" v-model="form.cbbizRemark" disabled/>
            </el-form-item>
          </el-col>
        </el-row>

      </el-card>
      <el-card class="form-card">
        <div slot="header" class="label-header-msg">
          <span>其他信息</span>
        </div>

        <el-row>
          <el-col :span="12">
            <el-form-item label="录入操作员" prop="mdTlrno">
              <el-input v-model="form.mdTlrno" :disabled="true" />
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="录入时间" prop="mdTime">
              <el-date-picker
                style="width: 100%"
                v-model="form.mdTime"
                value-format="yyyyMMddHHmmss"
                type="datetime"
                :disabled="true"
              />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="复核操作员" prop="ckTlrno">
              <el-input v-model="form.ckTlrno" :disabled="true" />
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="复核时间" prop="ckTime">
              <el-date-picker
                style="width: 100%"
                v-model="form.ckTime"
                value-format="yyyyMMddHHmmss"
                type="datetime"
                :disabled="true"
              />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="复核附言" prop="ckRemarks">
              <el-input type="textarea" v-model="form.ckRemarks" disabled/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="审核操作员" prop="audTlrno">
              <el-input v-model="form.audTlrno" :disabled="true" />
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="审核时间" prop="audTime">
              <el-date-picker
                style="width: 100%"
                v-model="form.audTime"
                value-format="yyyyMMddHHmmss"
                type="datetime"
                :disabled="true"
              />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="审核附言" prop="audRemarks">
              <el-input type="textarea" v-model="form.audRemarks" disabled/>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="24">
            <el-form-item label="授权附言" prop="authRemarks">
              <el-input type="textarea" v-model="form.authRemarks" maxlength="128" show-word-limit/>
            </el-form-item>
          </el-col>
        </el-row>
      </el-card>


    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button type="primary" @click="authorize">授权</el-button>
      <el-button type="danger" @click="reject">拒绝</el-button>
      <el-button @click="handleClose">关闭</el-button>
    </div>
  </el-dialog>
</template>
<script>
import HtAmountInput from "@/views/components/HtAmountInput";
import HtAmountUpper from "@/views/components/HtAmountUpper";
import { detail, authorize, reject } from "@/api/cnaps/baseBiz/send/auth";

export default {
  name: "detail115",
  components: {
    HtAmountInput,
    HtAmountUpper,
  },
  props: {
    dictMap: {
      type: Object,
      default: () => {
        return {};
      },
    },
  },
  data() {
    return {
      busTypeList: [],
      id: "",
      pkgNo: "",
      title: "",
      // 是否显示弹出层
      openState: false,
      // 表单参数
      form: {
        amount: "0.00",
      },
    };
  },
  mounted() {},
  methods: {
    // 关闭回掉
    handleClose() {
      this.openState = false;
    },
    show(id, pkgtype) {
      this.openState = true;
      this.id=id;
      if (id) {
        this.title = "大额汇兑业务授权";
        detail({
          id: id,
          pkgtype: pkgtype,
        }).then((res) => {
          this.$set(this, "form", res.result.data);
        });
      }
    },

    /** TODO提交按钮 */
    authorize: function () {
      let formData = this.form;
      console.log("formData", formData);
      //如果有ID 则是修改
      if (this.id) {
        formData.id = this.id;
        authorize(formData, "115").then((res) => {
          this.msgSuccess("授权成功");
          this.$emit("editComplete", true);
          this.openState = false;
        });
      }
    },
    reject() {
      let formData = this.form;
      formData.id = this.id;
      reject(formData, "115").then((res) => {
        this.msgSuccess("拒绝成功");
        this.$emit("editComplete", true);
        this.openState = false;
      });
    },

  },
};
</script>
<style>
.label-header-msg {
  font-weight: bold;
}

.form-card {
  margin-bottom: 10px;
}
</style>
